HAL RCC control functions migration ¶
This section provides information about the HAL RCC control functions migration.
In HAL2, the change is only a renaming of this functions. These functions return the value of frequency in Hz for the system clock.
HAL RCC get system clock frequency ¶
Function Description ¶
The
HAL_RCC_GetSysClockFreq
function returns the system clock frequency.
|
HAL1 |
HAL2 |
|
|---|---|---|
|
Function name |
HAL_RCC_GetSysClockFreq |
HAL_RCC_GetSYSCLKFreq |
|
Return Values |
System clock frequency in Hz |
System clock frequency in Hz |
Example Usage ¶
|
HAL1 |
HAL2 |
|---|---|
uint32_t sysclk_freq;
sysclk_freq = HAL_RCC_GetSysClockFreq();
|
uint32_t sysclk_freq;
sysclk_freq = HAL_RCC_GetSYSCLKFreq();
|
HAL RCC get PCLK2 frequency ¶
Function Description ¶
The
HAL_RCC_GetPCLK2Freq
function returns the PCLK2 frequency.
|
HAL1 |
HAL2 |
|
|---|---|---|
|
Function name |
HAL_RCC_GetPCLK2Freq |
HAL_RCC_GetPCLK2Freq |
|
Return Values |
PCLK2 frequency in Hz |
PCLK2 frequency in Hz |
HAL RCC get HCLK frequency ¶
Function Description ¶
The
HAL_RCC_GetHCLKFreq
function returns the HCLK frequency.
|
HAL1 |
HAL2 |
|
|---|---|---|
|
Function name |
HAL_RCC_GetHCLKFreq |
HAL_RCC_GetHCLKFreq |
|
Return Values |
HCLK frequency in Hz |
HCLK frequency in Hz |
HAL RCC get PCLK1 frequency ¶
Function Description ¶
The
HAL_RCC_GetPCLK1Freq
function returns the PCLK1 frequency.
|
HAL1 |
HAL2 |
|
|---|---|---|
|
Function name |
HAL_RCC_GetPCLK1Freq |
HAL_RCC_GetPCLK1Freq |
|
Return Values |
PCLK1 frequency in Hz |
PCLK1 frequency in Hz |
HAL RCC get PCLK3 frequency ¶
Function Description ¶
The
HAL_RCC_GetPCLK3Freq
function returns the PCLK3 frequency.
|
HAL1 |
HAL2 |
|
|---|---|---|
|
Function name |
HAL_RCC_GetPCLK3Freq |
HAL_RCC_GetPCLK3Freq |
|
Return Values |
PCLK3 frequency in Hz |
PCLK3 frequency in Hz |
In HAL1, one API manages all peripheral clock sources. In HAL2, this API is removed, and unitary APIs are provided to select the kernel clock source for each peripheral.
HAL RCCEx peripheral clock configuration ¶
Function Description ¶
The
HAL_RCCEx_PeriphCLKConfig
function configures the peripheral clock sources.
|
HAL1 |
HAL2 |
|
|---|---|---|
|
Function name |
HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(const RCC_PeriphCLKInitTypeDef *pPeriphClkInit); |
Function split into multiple unitary APIs:
|
Example Usage ¶
|
HAL1 |
HAL2 |
|---|---|
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USART1;
PeriphClkInitStruct.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
|
hal_status_t status;
status = HAL_RCC_USART1_SetKernelClkSource(HAL_RCC_USART1_CLKSOURCE_PCLK2);
|
HAL RCCEx get peripheral clock configuration ¶
Function Description ¶
In HAL1, one API retrieves all peripheral clock sources. In HAL2, this API is removed, and unitary APIs are provided to get the kernel clock source for each peripheral.
|
HAL1 |
HAL2 |
|
|---|---|---|
|
Function name |
void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *pPeriphClkInit); |
Function split into multiple unitary APIs:
|
Example Usage ¶
|
HAL1 |
HAL2 |
|---|---|
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
HAL_RCCEx_GetPeriphCLKConfig(&PeriphClkInitStruct);
|
hal_rcc_usart1_clk_src_t usart1_clk_src;
usart1_clk_src = HAL_RCC_USART1_GetKernelClkSource();
|
HAL RCCEx get peripheral clock frequency ¶
Function Description ¶
In HAL2, the peripheral clock frequency can be retrieved using two methods: unitary APIs for each peripheral instance or global APIs for peripherals.
|
HAL1 |
HAL2 |
|
|---|---|---|
|
Function name |
uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint64_t PeriphClk); |
Function split into multiple unitary APIs:
|
Example Usage ¶
|
HAL1 |
HAL2 |
|---|---|
uint32_t periph_clk_freq;
periph_clk_freq = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_USART1);
|
uint32_t usart1_clk_freq;
usart1_clk_freq = HAL_RCC_USART1_GetKernelClkFreq();
|